3.3.87 \(\int \cos ^2(e+f x) (a+b \sin ^2(e+f x)) \, dx\) [287]

Optimal. Leaf size=57 \[ \frac {1}{8} (4 a+b) x+\frac {(4 a+b) \cos (e+f x) \sin (e+f x)}{8 f}-\frac {b \cos ^3(e+f x) \sin (e+f x)}{4 f} \]

[Out]

1/8*(4*a+b)*x+1/8*(4*a+b)*cos(f*x+e)*sin(f*x+e)/f-1/4*b*cos(f*x+e)^3*sin(f*x+e)/f

________________________________________________________________________________________

Rubi [A]
time = 0.03, antiderivative size = 57, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, integrand size = 21, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.190, Rules used = {3270, 393, 205, 209} \begin {gather*} \frac {(4 a+b) \sin (e+f x) \cos (e+f x)}{8 f}+\frac {1}{8} x (4 a+b)-\frac {b \sin (e+f x) \cos ^3(e+f x)}{4 f} \end {gather*}

Antiderivative was successfully verified.

[In]

Int[Cos[e + f*x]^2*(a + b*Sin[e + f*x]^2),x]

[Out]

((4*a + b)*x)/8 + ((4*a + b)*Cos[e + f*x]*Sin[e + f*x])/(8*f) - (b*Cos[e + f*x]^3*Sin[e + f*x])/(4*f)

Rule 205

Int[((a_) + (b_.)*(x_)^(n_))^(p_), x_Symbol] :> Simp[(-x)*((a + b*x^n)^(p + 1)/(a*n*(p + 1))), x] + Dist[(n*(p
 + 1) + 1)/(a*n*(p + 1)), Int[(a + b*x^n)^(p + 1), x], x] /; FreeQ[{a, b}, x] && IGtQ[n, 0] && LtQ[p, -1] && (
IntegerQ[2*p] || (n == 2 && IntegerQ[4*p]) || (n == 2 && IntegerQ[3*p]) || Denominator[p + 1/n] < Denominator[
p])

Rule 209

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[b, 2]))*ArcTan[Rt[b, 2]*(x/Rt[a, 2])], x] /;
 FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a, 0] || GtQ[b, 0])

Rule 393

Int[((a_) + (b_.)*(x_)^(n_))^(p_)*((c_) + (d_.)*(x_)^(n_)), x_Symbol] :> Simp[(-(b*c - a*d))*x*((a + b*x^n)^(p
 + 1)/(a*b*n*(p + 1))), x] - Dist[(a*d - b*c*(n*(p + 1) + 1))/(a*b*n*(p + 1)), Int[(a + b*x^n)^(p + 1), x], x]
 /; FreeQ[{a, b, c, d, n, p}, x] && NeQ[b*c - a*d, 0] && (LtQ[p, -1] || ILtQ[1/n + p, 0])

Rule 3270

Int[cos[(e_.) + (f_.)*(x_)]^(m_)*((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)]^2)^(p_.), x_Symbol] :> With[{ff = FreeF
actors[Tan[e + f*x], x]}, Dist[ff/f, Subst[Int[(a + (a + b)*ff^2*x^2)^p/(1 + ff^2*x^2)^(m/2 + p + 1), x], x, T
an[e + f*x]/ff], x]] /; FreeQ[{a, b, e, f}, x] && IntegerQ[m/2] && IntegerQ[p]

Rubi steps

\begin {align*} \int \cos ^2(e+f x) \left (a+b \sin ^2(e+f x)\right ) \, dx &=\frac {\text {Subst}\left (\int \frac {a+(a+b) x^2}{\left (1+x^2\right )^3} \, dx,x,\tan (e+f x)\right )}{f}\\ &=-\frac {b \cos ^3(e+f x) \sin (e+f x)}{4 f}+\frac {(4 a+b) \text {Subst}\left (\int \frac {1}{\left (1+x^2\right )^2} \, dx,x,\tan (e+f x)\right )}{4 f}\\ &=\frac {(4 a+b) \cos (e+f x) \sin (e+f x)}{8 f}-\frac {b \cos ^3(e+f x) \sin (e+f x)}{4 f}+\frac {(4 a+b) \text {Subst}\left (\int \frac {1}{1+x^2} \, dx,x,\tan (e+f x)\right )}{8 f}\\ &=\frac {1}{8} (4 a+b) x+\frac {(4 a+b) \cos (e+f x) \sin (e+f x)}{8 f}-\frac {b \cos ^3(e+f x) \sin (e+f x)}{4 f}\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 0.07, size = 46, normalized size = 0.81 \begin {gather*} \frac {4 (4 a e+4 a f x+b f x)+8 a \sin (2 (e+f x))-b \sin (4 (e+f x))}{32 f} \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[Cos[e + f*x]^2*(a + b*Sin[e + f*x]^2),x]

[Out]

(4*(4*a*e + 4*a*f*x + b*f*x) + 8*a*Sin[2*(e + f*x)] - b*Sin[4*(e + f*x)])/(32*f)

________________________________________________________________________________________

Maple [A]
time = 0.25, size = 70, normalized size = 1.23

method result size
risch \(\frac {a x}{2}+\frac {b x}{8}-\frac {\sin \left (4 f x +4 e \right ) b}{32 f}+\frac {\sin \left (2 f x +2 e \right ) a}{4 f}\) \(40\)
derivativedivides \(\frac {b \left (-\frac {\left (\cos ^{3}\left (f x +e \right )\right ) \sin \left (f x +e \right )}{4}+\frac {\cos \left (f x +e \right ) \sin \left (f x +e \right )}{8}+\frac {f x}{8}+\frac {e}{8}\right )+a \left (\frac {\cos \left (f x +e \right ) \sin \left (f x +e \right )}{2}+\frac {f x}{2}+\frac {e}{2}\right )}{f}\) \(70\)
default \(\frac {b \left (-\frac {\left (\cos ^{3}\left (f x +e \right )\right ) \sin \left (f x +e \right )}{4}+\frac {\cos \left (f x +e \right ) \sin \left (f x +e \right )}{8}+\frac {f x}{8}+\frac {e}{8}\right )+a \left (\frac {\cos \left (f x +e \right ) \sin \left (f x +e \right )}{2}+\frac {f x}{2}+\frac {e}{2}\right )}{f}\) \(70\)
norman \(\frac {\left (\frac {a}{2}+\frac {b}{8}\right ) x +\left (2 a +\frac {b}{2}\right ) x \left (\tan ^{2}\left (\frac {f x}{2}+\frac {e}{2}\right )\right )+\left (2 a +\frac {b}{2}\right ) x \left (\tan ^{6}\left (\frac {f x}{2}+\frac {e}{2}\right )\right )+\left (3 a +\frac {3 b}{4}\right ) x \left (\tan ^{4}\left (\frac {f x}{2}+\frac {e}{2}\right )\right )+\left (\frac {a}{2}+\frac {b}{8}\right ) x \left (\tan ^{8}\left (\frac {f x}{2}+\frac {e}{2}\right )\right )+\frac {\left (4 a -b \right ) \tan \left (\frac {f x}{2}+\frac {e}{2}\right )}{4 f}-\frac {\left (4 a -b \right ) \left (\tan ^{7}\left (\frac {f x}{2}+\frac {e}{2}\right )\right )}{4 f}+\frac {\left (4 a +7 b \right ) \left (\tan ^{3}\left (\frac {f x}{2}+\frac {e}{2}\right )\right )}{4 f}-\frac {\left (4 a +7 b \right ) \left (\tan ^{5}\left (\frac {f x}{2}+\frac {e}{2}\right )\right )}{4 f}}{\left (1+\tan ^{2}\left (\frac {f x}{2}+\frac {e}{2}\right )\right )^{4}}\) \(197\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(cos(f*x+e)^2*(a+b*sin(f*x+e)^2),x,method=_RETURNVERBOSE)

[Out]

1/f*(b*(-1/4*cos(f*x+e)^3*sin(f*x+e)+1/8*cos(f*x+e)*sin(f*x+e)+1/8*f*x+1/8*e)+a*(1/2*cos(f*x+e)*sin(f*x+e)+1/2
*f*x+1/2*e))

________________________________________________________________________________________

Maxima [A]
time = 0.52, size = 74, normalized size = 1.30 \begin {gather*} \frac {{\left (f x + e\right )} {\left (4 \, a + b\right )} + \frac {{\left (4 \, a + b\right )} \tan \left (f x + e\right )^{3} + {\left (4 \, a - b\right )} \tan \left (f x + e\right )}{\tan \left (f x + e\right )^{4} + 2 \, \tan \left (f x + e\right )^{2} + 1}}{8 \, f} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(cos(f*x+e)^2*(a+b*sin(f*x+e)^2),x, algorithm="maxima")

[Out]

1/8*((f*x + e)*(4*a + b) + ((4*a + b)*tan(f*x + e)^3 + (4*a - b)*tan(f*x + e))/(tan(f*x + e)^4 + 2*tan(f*x + e
)^2 + 1))/f

________________________________________________________________________________________

Fricas [A]
time = 0.39, size = 47, normalized size = 0.82 \begin {gather*} \frac {{\left (4 \, a + b\right )} f x - {\left (2 \, b \cos \left (f x + e\right )^{3} - {\left (4 \, a + b\right )} \cos \left (f x + e\right )\right )} \sin \left (f x + e\right )}{8 \, f} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(cos(f*x+e)^2*(a+b*sin(f*x+e)^2),x, algorithm="fricas")

[Out]

1/8*((4*a + b)*f*x - (2*b*cos(f*x + e)^3 - (4*a + b)*cos(f*x + e))*sin(f*x + e))/f

________________________________________________________________________________________

Sympy [B] Leaf count of result is larger than twice the leaf count of optimal. 150 vs. \(2 (49) = 98\).
time = 0.18, size = 150, normalized size = 2.63 \begin {gather*} \begin {cases} \frac {a x \sin ^{2}{\left (e + f x \right )}}{2} + \frac {a x \cos ^{2}{\left (e + f x \right )}}{2} + \frac {a \sin {\left (e + f x \right )} \cos {\left (e + f x \right )}}{2 f} + \frac {b x \sin ^{4}{\left (e + f x \right )}}{8} + \frac {b x \sin ^{2}{\left (e + f x \right )} \cos ^{2}{\left (e + f x \right )}}{4} + \frac {b x \cos ^{4}{\left (e + f x \right )}}{8} + \frac {b \sin ^{3}{\left (e + f x \right )} \cos {\left (e + f x \right )}}{8 f} - \frac {b \sin {\left (e + f x \right )} \cos ^{3}{\left (e + f x \right )}}{8 f} & \text {for}\: f \neq 0 \\x \left (a + b \sin ^{2}{\left (e \right )}\right ) \cos ^{2}{\left (e \right )} & \text {otherwise} \end {cases} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(cos(f*x+e)**2*(a+b*sin(f*x+e)**2),x)

[Out]

Piecewise((a*x*sin(e + f*x)**2/2 + a*x*cos(e + f*x)**2/2 + a*sin(e + f*x)*cos(e + f*x)/(2*f) + b*x*sin(e + f*x
)**4/8 + b*x*sin(e + f*x)**2*cos(e + f*x)**2/4 + b*x*cos(e + f*x)**4/8 + b*sin(e + f*x)**3*cos(e + f*x)/(8*f)
- b*sin(e + f*x)*cos(e + f*x)**3/(8*f), Ne(f, 0)), (x*(a + b*sin(e)**2)*cos(e)**2, True))

________________________________________________________________________________________

Giac [A]
time = 0.48, size = 41, normalized size = 0.72 \begin {gather*} \frac {1}{8} \, {\left (4 \, a + b\right )} x - \frac {b \sin \left (4 \, f x + 4 \, e\right )}{32 \, f} + \frac {a \sin \left (2 \, f x + 2 \, e\right )}{4 \, f} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(cos(f*x+e)^2*(a+b*sin(f*x+e)^2),x, algorithm="giac")

[Out]

1/8*(4*a + b)*x - 1/32*b*sin(4*f*x + 4*e)/f + 1/4*a*sin(2*f*x + 2*e)/f

________________________________________________________________________________________

Mupad [B]
time = 13.66, size = 67, normalized size = 1.18 \begin {gather*} x\,\left (\frac {a}{2}+\frac {b}{8}\right )+\frac {\left (\frac {a}{2}+\frac {b}{8}\right )\,{\mathrm {tan}\left (e+f\,x\right )}^3+\left (\frac {a}{2}-\frac {b}{8}\right )\,\mathrm {tan}\left (e+f\,x\right )}{f\,\left ({\mathrm {tan}\left (e+f\,x\right )}^4+2\,{\mathrm {tan}\left (e+f\,x\right )}^2+1\right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(cos(e + f*x)^2*(a + b*sin(e + f*x)^2),x)

[Out]

x*(a/2 + b/8) + (tan(e + f*x)^3*(a/2 + b/8) + tan(e + f*x)*(a/2 - b/8))/(f*(2*tan(e + f*x)^2 + tan(e + f*x)^4
+ 1))

________________________________________________________________________________________